<!-- 页头组件，包含跳转、登录组件等 -->
<script setup lang="ts">
import {h, ref} from "vue";
import login from "@/components/loginComponent.vue";
import notice from "@/components/noticeComponent.vue";
import {MoreFilled} from "@element-plus/icons-vue";
import {useRoute, useRouter} from "vue-router";
const route = useRoute();
const router = useRouter();
const logoimg = $ref("");
const menuData = $ref([
    {
        index: 0,
        title: "新论坛",
        href: "/#/bbs",
    },
    {
        index: 1,
        title: "活动专区",
        href: "/#/event",
    },
    {
        index: 2,
        title: "图形实验室",
        href: "#ccc",
    },
    {
        index: 3,
        title: "原爱思资源平台",
        href: "http://is.cau.edu.cn/",
    },
]);
let selectIndex = $ref(0);
let showMinMenuContent = $ref(false);
const handleHover = (index: number) => {
    showMenuContent = true;
    selectIndex = index;
};
const handleLeave = () => {
    showMenuContent = false;
};
const handleClick = () => {
    showMinMenuContent = !showMinMenuContent;
};

let showMenuContent = $ref(false);
const handleSelect = (key: string, keyPath: string[]) => {
    console.log(key, keyPath);
};
const goto = (url: string) => {
    window.location.href = url;
};
const noticeRef = ref()
</script>
<template>
    <div @mouseleave="handleLeave">
        <div class="header">
            <div class="header__wrap">
                <div class="logo">
                    <div class="logo__wrap">
                        <img src="logo1.jpg" alt=""
                            style="margin: 10px; width: 50px; height: 50px"
                            @click="goto('/')" class="hp" />
                    </div>
                </div>
                <div class="menu">
                    <ul class="menuitem hp"
                        @mouseover="handleHover(item.index)"
                        v-for="item in menuData">
                        <li @click="goto(item.href)">{{
                                item.title
                        }}</li>
                    </ul>
                </div>
                <div style="" class="fv left__wrap">
                    <div class="fh">
                        <notice />
                        <login />
                    </div>
                </div>
            </div>
        </div>

        <div
            style="position: fixed; width: 100%; z-index: 100">
            <div class="menu-hover__m"
                v-show="showMinMenuContent"
                @mouseleave="showMinMenuContent = false">
                <el-scrollbar height="400px">
                </el-scrollbar>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">
.header {
    background-color: transparent;
    position: relative;
    z-index: 100;

    .header__wrap {
        display: flex;
        flex-flow: nowrap row;
        width: 100%;
        justify-content: space-between;
        background: #fffffff6;
        height: 65px;
    }

    .logo {
        width: 200px;
        display: flex;
        align-items: center;
    }

    .logo__wrap {
        display: flex;
        flex-direction: row;
        margin: 0 auto;
        width: 70px;
        height: 70px;
    }

    .left__wrap {
        margin: 0 30px;
        min-width: 165px;
    }

    .menu {
        display: flex;
        font-size: 14px;
        align-items: center;
        min-width: 510px;
    }

    .menuitem {
        /* line-height: 85px; */
        margin: 0 20px;
        font-size: 1.3em;
        list-style: none;

        position: relative;
        transition: all 0.3s ease;
    }

    .menuitem:hover {
        color: dodgerblue;
    }

    .menuitem::after {
        content: "";
        width: 0%;
        height: 4px;
        bottom: -1em;
        left: -1px;
        position: absolute;
        border-radius: 2px;
        background-color: dodgerblue;

        transition: all 0.3s ease;
    }

    .menuitem:hover::after {
        width: 100%;
    }

    .menu-hover__m {
        animation: hidetip 0.2s 1;
        width: 100%;
        height: 420px;
        margin-top: -20px;
        z-index: 1000;
        background: #fff;
    }
}

.header:after {
    content: "";
    width: 100%;
    display: block;
    /* height: 20px; */
}



/* @media (max-width: 920px) { */

/*     .menu, */
/*     .menu-hover__g, */
/*     .left__wrap { */
/*         display: none; */
/*     } */

/*     .c2 { */
/*         justify-content: start; */
/*         margin: 0 20px; */
/*         margin-bottom: 20px; */
/*         width: 80px; */
/*     } */
/* } */

/* @media (min-width: 920px) { */

/*     .menu-hover__m, */
/*     .left__wrap__min { */
/*         display: none; */
/*     } */
/* } */

.menu-hover__g {
    /* margin-top: 100%; */
    /* transform: translateY(-100%); */
    animation: hidetip 0.2s 1;
    width: 100%;
    min-height: 300px;
}

.menu__hover__right .title {
    color: #555;
    margin: 15px 0;
}

@keyframes hidetip {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.menu-hover__g:after,
.menu-hover__m:after {
    content: "";
    width: 100%;
    display: block;
    height: 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), transparent);
}

.menu__hover__right {
    width: 300px;
    right: 0;
    overflow: hidden;
    margin-bottom: 30px;
}

.col1 {
    min-height: 100px;
}

.c1 {
    justify-content: start;
    margin: 0 50px;
    margin-bottom: 20px;
    width: 80px;
}

.greybg {
    z-index: 1000;
    height: 100%;
    /* margin-top: -100%; */
    background-color: #eee;
}
</style>
